package com.example.medicine.controller;

import com.example.medicine.Bean.zhengzhuang;
import com.example.medicine.Mapper.zyjbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/zyjb")
public class zyjbController {
    @Autowired
    private zyjbMapper zyjbMapper;
    /**
     * 接收zhengzhuangList请求，返回数据库的zhengzhuang表内西医的所有内容，格式为json
     * @return
     */
    @GetMapping("/")
    public List<zhengzhuang> getzyjbList(){
        return zyjbMapper.getAll();
    }
    /**
     * 接收insertzhengzhuang请求，向zhengzhuang中插入内容
     */
    @PostMapping("/")
    public void inserzyjb(@RequestBody zhengzhuang zhengzhuang){
        zyjbMapper.insert(zhengzhuang);
    }

    @PutMapping("/")
    public void updatezyjb(@RequestBody zhengzhuang zhengzhuang){
        zyjbMapper.update(zhengzhuang);
    }

    @DeleteMapping("/{id}")
    public void deletezyjb(@PathVariable int id){
        zyjbMapper.deleteById(id);
    }
}
